using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper {
	public class FeatureMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public FeatureMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {
			_cfg.CreateMap<feature_dto, Feature>()
				.ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
				.ForMember(dest => dest.Name, src => src.MapFrom(c => c.name))
				.ForMember(dest => dest.Type, src => src.MapFrom(c => c.type))
				.ForMember(dest => dest.ParentId, src => src.MapFrom(c => c.parent_id))
				.ForMember(dest => dest.Depth, src => src.Ignore())
				.ForMember(dest => dest.Path, src => src.Ignore())
				.ForMember(dest => dest.Remark, src => src.MapFrom(c => c.remark))
				.ForMember(dest => dest.Url, src => src.MapFrom(c => c.url))
				.ForMember(dest => dest.GotoUrl, src => src.MapFrom(c => c.goto_url))
				.ForMember(dest => dest.Icon, src => src.MapFrom(c => c.icon))
				.ForMember(dest => dest.Sort, src => src.MapFrom(c => c.sort));
			_cfg.CreateMap<Feature, feature_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.name, src => src.MapFrom(c => c.Name))
				.ForMember(dest => dest.type, src => src.MapFrom(c => c.Type))
				.ForMember(dest => dest.parent_id, src => src.MapFrom(c => c.ParentId))
				.ForMember(dest => dest.depth, src => src.MapFrom(c => c.Depth))
				.ForMember(dest => dest.path, src => src.MapFrom(c => c.Path))
				.ForMember(dest => dest.remark, src => src.MapFrom(c => c.Remark))
				.ForMember(dest => dest.url, src => src.MapFrom(c => c.Url))
				.ForMember(dest => dest.goto_url, src => src.MapFrom(c => c.GotoUrl))
				.ForMember(dest => dest.icon, src => src.MapFrom(c => c.Icon))
				.ForMember(dest => dest.sort, src => src.MapFrom(c => c.Sort));
		}
	}
}
